import pygame

from role.Role import Role


class Explode(Role):

    def __init__(self, tank):
        self.images = []
        for i in range(1, 5):
            self.images.append(pygame.image.load("resources/born" + str(i) + ".gif"))
        for i in range(1, 9):
            self.images.append(pygame.image.load("resources/blast" + str(i) + ".gif"))

        super().__init__(tank.screen, self.images[0])
        self.rect.left = tank.rect.left + (tank.width - self.width) // 2
        self.rect.top = tank.rect.top + (tank.height - self.height) // 2
        self.play_index = 0

    def play(self):
        if not self.live or self.play_index >= len(self.images):
            self.live = False
            return 1
        self.image = self.images[self.play_index]
        self.draw()
        self.play_index += 1
